<template>
  <vol-box
    :lazy="true"
    v-model="model"
    title="选择产品"
    :height="400"
    :width="1200"
    :padding="5"
    :onModelClose="onModelClose"
  >
    <goodsFittings ref="goodsFittings"></goodsFittings>
    <template #footer>
      <div>
        <el-button type="primary" size="small" @click="detailOnSelect"
          >确认</el-button
        >
      </div>
    </template>
  </vol-box>
</template>
  
  <script>
import VolBox from "@/components/basic/VolBox.vue";
import goodsFittings from "@/views/produceinfo/goods_fittings/q_goods_fittings.vue";
export default {
  components: {
    "vol-box": VolBox,
    goodsFittings,
  },
  data() {
    return {
      model: false,
    };
  },
  methods: {
    async onModelClose() {
      console.log("关闭");
      // this.$refs.goodsFittings.searchFormFields.AuditStatus = "1";
      // this.$refs.goodsFittings.searchFormFields.PaymentState = "0";
      await this.$refs.goodsFittings.$refs.grid.search();
    },
    open() {
      this.model = true;
      // this.$refs.goodsFittings.searchFormFields.AuditStatus = "1";
      // this.$refs.goodsFittings.searchFormFields.PaymentState = "0";
      // this.$refs.goodsFittings.table.load(null, true);
    },
    async detailOnSelect() {
      let rowObj = this.$refs.goodsFittings.$refs.grid.getSelectRows();
      if (rowObj.length == 1) {
        this.$emit("parentCall", ($parent) => {
        //   console.log($parent.Goods_fittings=rowObj[0].Goods_fittings);
        //   $parent.Goods_fittings=rowObj[0].Goods_fittings
          $parent.editFormFields.Goods_sub = rowObj[0].Goods_sub;
          $parent.editFormFields.Goods_name = rowObj[0].Goods_name;
          $parent.editFormFields.Goods_num = 1;
        //   let url = "api/q_goods_fittings/getDetailPage";
        //   let params = {
        //     order: "desc",
        //     page: 1,
        //     rows: 100,
        //     sort: "Goods_sub",
        //     value: rowObj[0].Goods_fittings,
        //     wheres: "[]",
        //   };
        //   this.http.post(url, params, "").then((reslut) => {
        //     console.log("reslut", reslut);
        //     if (reslut.rows) {
        //         reslut.rows.forEach(element => {
        //             element.Production_state= 1
        //         });
        //       $parent.$refs.detail.rowData.unshift(...reslut.rows);
        //     }
        //   });
        });

        this.onModelClose();
        return (this.model = false);
      } else {
        if (this.messageError) {
          this.messageError.close();
        }
        this.messageError = this.$message.error("请选择一个产品");
      }
    },
  },
};
</script>
  
  <style>
</style>